package org.sky.model;

import org.sky.util.ExcelResources;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@org.hibernate.annotations.Entity(dynamicUpdate = true, dynamicInsert = true)
public class Person implements Serializable {

    /**
     * 用户编号
     */
    private int id;

    /**
     * 登录帐号
     */
    private String userName;

    /**
     * 登录密码
     */
    private String password;

    /**
     * 电子邮箱
     */
    private String email;

    /**
     * 联系电话
     */
    private String phone;

    /**
     * 信誉度
     */
    private int credit = 100;

    /**
     * 使用次数
     */
    private int level = 0;
    /**
     * 账号状态
     */
    private boolean enabled = true;
    /**
     * 关联权限组
     */
    private String authority;

    @Id
    @GeneratedValue
    @ExcelResources(title = "编号", order = 1)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(length = 18, nullable = false, unique = true)
    @ExcelResources(title = "账号", order = 8)
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(length = 50, nullable = false)
    @ExcelResources(title = "密码", order = 9)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(length = 20, nullable = false)
    @ExcelResources(title = "邮箱", order = 4)
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(length = 13)
    @ExcelResources(title = "手机号码", order = 5)
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Column(length = 4, nullable = false, columnDefinition = "INT default 100")
    @ExcelResources(title = "信誉度", order = 3)
    public int getCredit() {
        return credit;
    }

    public void setCredit(int credit) {
        this.credit = credit;
    }

    @Column(length = 4, nullable = false, columnDefinition = "INT default 0")
    @ExcelResources(title = "使用次数", order = 2)
    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    @ExcelResources(title = "权限", order = 7)
    public String getAuthority() {
        return authority;
    }

    public void setAuthority(String authority) {
        this.authority = authority;
    }


    @Column(nullable = false, columnDefinition = "BIT default 1")
    @ExcelResources(title = "账号状态", order = 6)
    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public Person(int id, String authority, int credit, String email, boolean enabled,
                  int level, String password, String phone, String userName){
        super();
        this.id = id;
        this.authority = authority;
        this.credit = credit;
        this.email = email;
        this.enabled = enabled;
        this.level = level;
        this.password = password;
        this.phone = phone;
        this.userName = userName;
    }

    public Person(){
        super();
    }

    @Override
    public String toString() {
        return "RoomUsed [id=" + id + ",authority=" + authority + ", credit=" + credit + ", email="
                + email + ", enabled=" + enabled + ", level=" + level + ", password=" + password +", phone"
                +  ", singerNum="+ phone +  ", userName=" + userName + "]";
    }

}